package com.client.buttlefield.ui;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Vector;

import javafx.scene.paint.Color;


public class Controller implements ButtleListener{
    
    
	public Controller(){
		
		Random rand = new Random();
		Byte i=0;
		for(; i<5; ++i){
			Participant p = new Participant(rand.nextDouble()*500, rand.nextDouble()*300, Color.BLUE);
			p.setIdent(i);
			p.assign(false);
		}
		
		for(; i<7; ++i){
			Participant p = new Participant(rand.nextDouble()*500, rand.nextDouble()*300, Color.RED);
			p.setIdent(i);
			p.assign(true);
		}
		
		createButtleList();
	}
	
	void createButtleList(){
		Buttlefield.createButtle().addButtleListener(this);
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Controller();
	}

	@Override
	public void FireMove(ButtleEvent btl) {
		System.out.println("get  event from buttle");
		Participant p =(Participant) btl.getSource();
		double x= btl.targetX;
		double y = btl.targetY;
		int t = btl.getontime;
		p.moving(x, y, t);
	}

}
